<template>
    <div>
        <div>
        <van-nav-bar title="我的发布" left-arrow  @click-left="onClickLeft"/> 
        </div>
        <div align="center">
        <p>用户：{{uN}}</p>
        </div>
        <br>
    <div v-for="(card,index) in mycards" :key="index">
    <van-card
    v-bind:title="card.goods_name"
    v-bind:desc="card.goods_desc"  
    v-bind:num="card.goods_num"
    v-bind:price="card.goods_price"
    :thumb="card.goods_picture"
    >
        <div slot="footer">
    <van-button  size="normal" type="primary" @click="goodDetails(index)">详情</van-button>
    </div>
    </van-card> 
     
    </div>
    </div>
</template>
<script>
import axios from "axios";
import { Dialog } from 'vant';
export default {
data() {
    return {
     
    }
},
computed:{
    uN(){
        return this.$store.state.uN
    },
    mycards(){
         return this.$store.state.mycards
    }


},
mounted:function(){
    axios({
        method: "post",
        url: "http://localhost:3000/Mygoods",
        data: {    
         
        goods_master: this.uN
        },
        headers: {
        "Content-Type": "text/plain"
        }
    }).then(result => {
        if(result.data=="没有数据"){
          this.$store.state.mycards=[]
        }else{
        console.log(result);
        this.$store.state.mycards=result.data;
        }

    })
},
methods:{
        goodDetails(index){
       this.$store.commit('mygooddetail',index)     
      this.$router.push({path:'/goodMsg',})
    },
    //返回
    onClickLeft() {
    this.$router.go(-1)
    }
}
}
</script>
<style>

</style>